package cn.kbyue.retrydemo.controller;

import cn.kbyue.retrydemo.service.RetryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    @Autowired
    private RetryService retryService;

    @GetMapping("/retry")
    public ResponseEntity<Integer> retryTest(@RequestParam(name = "code") Integer code) {
        int retry = 0;
        try {
            retry = retryService.testRetry(code);
        } catch (Exception e) {
            System.out.println("服务器响应失败!" + e.getMessage());
        }
        return ResponseEntity.ok().body(retry);
    }

}
